package com.hu.zhcc.shiro.service.Responsitory;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.shiro.dao.RSportMapper;
import com.hu.zhcc.shiro.entity.Reponsitory.RSport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SportServiceImpl implements SportService {

    @Autowired
    private RSportMapper sportMapper;

    @Override
    public Page<RSport> sportAll(Map<String, String> map, RSport sport) {
        Integer offset = Integer.valueOf(map.get("offset"));
        Integer limit = Integer.valueOf(map.get("limit"));
        PageHelper.startPage(offset, limit);
        List<RSport> rSports = sportMapper.selectAll(sport);
        PageInfo<RSport> rSportPageInfo = new PageInfo<>(rSports);
        return new Page<RSport>(rSportPageInfo.getTotal(), rSports);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return sportMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertSelective(RSport record) {
        return sportMapper.insertSelective(record);
    }

    @Override
    public RSport beforeSelectByid(int id) {
        return sportMapper.beforeSelectByid(id);
    }

    @Override
    public int updateByPrimaryKeySelective(RSport record) {
        return sportMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public List<RSport> findSportNameList() {
        return sportMapper.findSportNameList();
    }
}
